Main Page | Class List | Class Members

BustaNetServer Class Reference

Server network module for Busta'Sandwich. More...

#include <BustaNetServer.h>

List of all members.

Public Member Functions

 BustaNetServer ()
 Constructor.
 ~BustaNetServer ()
 Destructor.
char * init (Uint16 servport)
 Initialize the server.
void sendAccept (int to_client, bool response, char *message)
 Sends a connection response to a connecting client.
void sendCharacterSelectedAllO (client *sel_client, BustaModelCharacter character)
 Sends a character selection notification to all connected clients.
void sendCharacterSelectCursorAllO (client *sel_client, netPosition cursor)
 Sends a character selection cursor udpate to all connected clients.
void sendCharacterSelectModeAll ()
 Notifies all connected clients that multiplayer character selection is taking place.
void sendConnectedAllO (client *sel_client)
 Notifies all connected clients another player has joined the game.
void sendDisconnectedAllO (client *disc_client, char *message)
 Sends a disconnect notification to all connected clients.
void sendEndAll ()
 Sends an end game message to all players.
void sendPlayerLostAllO (client *lost_player)
 Sends a notification to all client when one client has lost in the current game.
void sendPlayerReadyAllO (client *ready_player)
 Sends a notification to all client when a player has selected ready.
void sendSandwichAllO (client *target_client, client *from_client, SpecialSandwich sandwich)
 Sends a notification to all client opponents that a special sandwich has been sent to a player.
void sendGameStartAll ()
 Notifies all connected clients to start the multiplayer game.
void sendUpdateAll ()
 Sends client game state information to all connected clients.
void setDebug (bool OnOff)
 Sets the server in debug mode.
void setExtrememDebug (bool OnOff)
 Sets the server in extreme debug mode.
void setMaxClients (int maxC)
 Sets the maximum number of allowed connections.
int getMaxClients ()
 Gets the maximum number of allowed connections.
void setName (char *servname)
 Sets the name of the server.
char * getName ()
 Gets the name of the server.
int setStateAutoAccept (int num_clients)
 Auto accepts clients and adds them to the socket set.
int setStateAccept ()
 Sets the server in client connection accepting mode.
int setStateCharSelect ()
 Sets the server in client character selection mode.
int setStateGame ()
 Sets the server in game mode.


Detailed Description

Server network module for Busta'Sandwich.

Standalone server class for hosting and handling multiplayer games of Busta'Sandwich..


Constructor & Destructor Documentation

BustaNetServer::BustaNetServer  ) 
 

Constructor.

BustaNetServer::~BustaNetServer  ) 
 

Destructor.


Member Function Documentation

int BustaNetServer::getMaxClients  ) 
 

Gets the maximum number of allowed connections.

Returns the maximum number of simultaneous connections allowed by clients at any given time.

char * BustaNetServer::getName  ) 
 

Gets the name of the server.

Returns the server identification name.

char * BustaNetServer::init Uint16  servport  ) 
 

Initialize the server.

Initializes SDL and SDLNet. A socket to connect to the server is created for the server's ip address on the specified port.

Parameters:
servport The port number to host the game on
Returns:
Returns a error message if an error occurs during initialization. On no error null is returned.

void BustaNetServer::sendAccept int  to_client,
bool  response,
char *  message
 

Sends a connection response to a connecting client.

Responds to a client's connection attempt. The client is sent a message detailing whether or not the connection was allowed, a message describing why or why not the connection was allowed, and the player's identification number if the connection was accepted.

Parameters:
to_client The id number of the accepted client
response Response to the connection attempt. True for allow, false for deny
message Description of the server's response; why allowed or denied

void BustaNetServer::sendCharacterSelectCursorAllO client sel_client,
netPosition  cursor
 

Sends a character selection cursor udpate to all connected clients.

Sends an update message to all clients except the selected client that the player has moved the cursor and the location.

Parameters:
sel_client The pointer to the selected client's struct
cursor The character cursor location of the client

void BustaNetServer::sendCharacterSelectedAllO client sel_client,
BustaModelCharacter  character
 

Sends a character selection notification to all connected clients.

Sends a notification message to all clients except the selected client that the player has selected a character and what it is.

Parameters:
sel_client The pointer to the selected client's struct
character The character selected by the client

void BustaNetServer::sendCharacterSelectModeAll  ) 
 

Notifies all connected clients that multiplayer character selection is taking place.

A message is sent to all clients connected to the server that all clients are to now select a multiplayer character.

void BustaNetServer::sendConnectedAllO client sel_client  ) 
 

Notifies all connected clients another player has joined the game.

A message that notifies all of the other clients that a player has connected. Used in the connection screen for example.

void BustaNetServer::sendDisconnectedAllO client disc_client,
char *  message
 

Sends a disconnect notification to all connected clients.

Sends a notification message to all clients that are still connected when a client disconnects from the server. Includes details as to why client disconnected.

Parameters:
disc_client The pointer to the disconnected client's struct
message Reason for client disconnection

void BustaNetServer::sendEndAll  ) 
 

Sends an end game message to all players.

Needs some commenting...

void BustaNetServer::sendGameStartAll  ) 
 

Notifies all connected clients to start the multiplayer game.

A message is sent to all connected clients that the multiplayer game is now starting.

void BustaNetServer::sendPlayerLostAllO client lost_player  ) 
 

Sends a notification to all client when one client has lost in the current game.

A notification that a client has lost in the current multiplayer game is sent to all other connected clients. The player who has lost is not notified.

Parameters:
lost_player The pointer to the player's struct who has lost

void BustaNetServer::sendPlayerReadyAllO client ready_player  ) 
 

Sends a notification to all client when a player has selected ready.

A notification that a client has selected ready in the connection screen

Parameters:
ready_player The pointer to the player's struct who is ready

void BustaNetServer::sendSandwichAllO client target_client,
client from_client,
SpecialSandwich  sandwich
 

Sends a notification to all client opponents that a special sandwich has been sent to a player.

A notification that a client has sent a special sandwich to another opponent

Parameters:
target_client The pointer to the client's struct who recieved the sandwich
from_client The pointer to the client's struct who sent the sandwich
sandwich The type of special sandwich sent

void BustaNetServer::sendUpdateAll  ) 
 

Sends client game state information to all connected clients.

Sends game state information to all connected clients. This includes the brief information required by each player as well as the detailed game state requested by each client.

void BustaNetServer::setDebug bool  OnOff  ) 
 

Sets the server in debug mode.

Turns on debugging output to the console for the server.

Parameters:
OnOff Boolean to turn on or off debugging output

void BustaNetServer::setExtrememDebug bool  OnOff  ) 
 

Sets the server in extreme debug mode.

Turns on extreme debugging output to the console for the server.

Parameters:
OnOff Boolean to turn on or off extreme debugging output

void BustaNetServer::setMaxClients int  maxC  ) 
 

Sets the maximum number of allowed connections.

Specifies the maximum number of simultaneous connections allowed by clients at any given time.

Parameters:
maxC The maximum number of clients to allow

void BustaNetServer::setName char *  servname  ) 
 

Sets the name of the server.

Assigns the server an identification name.

Parameters:
servname The name to give the server

int BustaNetServer::setStateAccept  ) 
 

Sets the server in client connection accepting mode.

The server is now in a state to accept incoming TCP connections from clients. The server may leave this mode when all connected clients have sent a ready notification to the server and there is at least two connected clients.

Returns:
Returns an integer greater than or equal to zero if the above condition is met. A negative integer is returned on error in this mode.

int BustaNetServer::setStateAutoAccept int  num_clients  ) 
 

Auto accepts clients and adds them to the socket set.

The server automatically accepts clients and adds them to the socket set. Used only for testing other functionality. Does not send any of the notification messages of a standard accept loop.

Parameters:
num_clients The number of clients to wait for
Returns:
Returns an integer greater than or equal to zero if the above condition is met. A negative integer is returned on error in this mode.

int BustaNetServer::setStateCharSelect  ) 
 

Sets the server in client character selection mode.

The server is now in a state that allows clients to select a multiplayer character. The server leaves this mode when all connected clients have sent a selected character to the server. The server may also leave this mode if client disconnects occur leaving less than two connected clients.

Returns:
Returns an integer greater than zero if all connected clients have selected a character. Returns zero if client disconnects leaves less than two players. Returns a negative value on error.

int BustaNetServer::setStateGame  ) 
 

Sets the server in game mode.

The server is now in multiplayer game mode. All clients are currently playing the game. The server leaves this mode when all but one player has lost in the game or less than two clients remain connected to the server while in this mode.

Returns:
Returns an integer greater than zero if a winner is determined. Returns 0 if less than two clients are connected and a negative value on error.


Generated on Sun Aug 14 22:24:54 2005 for BustaSandwich Server by  doxygen 1.4.2-20050421